package org.example.servletpractice.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter(urlPatterns = "/*")
public class TestFilter implements Filter {

    private static Integer count = 0;

    @Override
    public void init(FilterConfig config) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("网站名称: " + servletRequest.getParameter("site"));
        count++;
        // 输出计数器
        System.out.println("网站访问统计："+ count );
        filterChain.doFilter(servletRequest,servletResponse);
    }
}
